// @ts-ignore
import { glob } from 'astro/loaders';
import { defineCollection, z } from 'astro:content';

const blog = defineCollection({
	// Load Markdown and MDX files in the `src/content/blog/` directory.
	loader: glob({ base: './src/content/blog', pattern: '**/*.{md,mdx}' }),
	// Type-check frontmatter using a schema
	schema: z.object({
		title: z.string(),
		description: z.string(),
		// Transform string to Date object
		pubDate: z.coerce.date(),
		updatedDate: z.coerce.date().optional(),
		heroImage: z.string().optional(),
	}),
});
const contact_page = defineCollection({
	schema: z.object({
		title: z.string().optional(),
		description: z.string().optional(),
		draft: z.boolean().optional(),
		info: z.object({
			title: z.string().optional(),
			description: z.string().optional(),
			contacts: z.array(z.string()).optional()
		}).optional()
	})
})

const homepage = defineCollection({
	schema: z.object({
		banner: z.object({
			title: z.string().optional(),
			content: z.string().optional(),
			image: z.string().optional(),
			button: z.object({
				label: z.string(),
				link: z.string().default("#"),
				enable: z.boolean().default(true)
			})
		}).optional(),
		feature: z.object({
			title: z.string().optional(),
			features: z.array(z.object({name: z.string().optional(), icon: z.string().optional(), content: z.string().optional()})),
		}).optional(),
		services: z.array(z.object({
			title: z.string().optional(),
			content: z.string().optional(),
			images: z.array(z.string()).optional(),
			button: z.object({
				label: z.string(),
				link: z.string().default("#"),
				enable: z.boolean().default(true)
			}).optional()
		})).optional(),
		workflow: z.object({
			title: z.string().optional(),
			description: z.string().optional(),
			image: z.string()
		}).optional(),
		call_to_action: z.object({
			title: z.string().optional(),
			content: z.string().optional(),
			image: z.string(),
			button: z.object({
				label: z.string(),
				link: z.string().default("#"),
				enable: z.boolean().default(true)
			}).optional()
		}).optional()
	}),
});
export const collections = { blog, contact: contact_page , homepage};
